/****************************************************************************
 * Elisa 1.0                                                                *
 *--------------------------------------------------------------------------*
 * Author: Laurent Granvilliers, Vincent Sorin                              *
 * Copyright (c) 2004 Laboratoire d'Informatique de Nantes Atlantique       *
 *--------------------------------------------------------------------------*
 * Elisa is distributed WITHOUT ANY WARRANTY. Read the associated           *
 * COPYRIGHT file for more details.                                         *
 *--------------------------------------------------------------------------*
 * elisa_interval_strategy.h                                                  *
 ****************************************************************************/

/**
 * @file elisa_interval_strategy.h
 * @brief Classes for strategies to be used by interval solvers.
 */


#ifndef _ELISA_INTERVAL_STRATEGY_H
#define _ELISA_INTERVAL_STRATEGY_H


#include "elisa_defs.h"
#include "elisa_solver.h"
#include "elisa_reduction.h"
#include "elisa_fp_reduction.h"
#include "elisa_box_reduction.h"
#include "elisa_hull_reduction.h"
#include "elisa_newton_reduction.h"
#include "elisa_model.h"
#include "elisa_constraint.h"
#include "elisa_and_model.h"
#include "elisa_reduction_factory.h"
#include "elisa_natural_interval_form.h"

NAMESPACE_ELISA
/**
 * @ingroup Reduction
 * @class AndReductionFactory
 * @brief Generation of a set of reductions from an interval "and" :
 * reductions for box-consistency and a reduction for the interval Newton method
 */
class FPNewtonFactory : public ReductionFactory
{
public:
	/**
 	 * Constructor
 	 */
	FPNewtonFactory()
	{
	}

	/**
 	 * Destructor
 	 */
	~FPNewtonFactory()
	{
	}

	/**
 	 * Generation of reductions in s
 	 * @param first iterator pointing to the first constraint of the CSP
 	 * @param last iterator pointing to the last constraint of the CSP
 	 */
	void create(ModelRep *mo, SetReduction & s);
};


/**
 * @ingroup Reduction
 * @class FPFactory
 * @brief Generation of a set of reductions from an AndModel:
 */
class FPFactory : public ReductionFactory
{
public:
	/**
 	 * Constructor
 	 */
	FPFactory ()
	{
	}

	/**
 	 * Destructor
 	 */
	~FPFactory ()
	{
	}

	/**
 	 * Generation of reductions in s
 	 * @param first iterator pointing to the first constraint of the CSP
 	 * @param last iterator pointing to the last constraint of the CSP
 	 */
	void create(ModelRep *mo, SetReduction & s);
};

/**
 * @ingroup Reduction
 * @class BC3ReviseFactory
 * @brief Generation of a set of reductions for box-consistency
 * @see BoxReduction
 */
class BC3ReviseFactory : public ReductionFactory
{
public:
	/**
 	 * Constructor
 	 * @param cons the factory for the intervalForm
 	 */
	BC3ReviseFactory (IntervalFormFactory *cons)
	{
		_cons = cons;
	}

	/**
 	 * Destructor
 	 * @post the factory for intervalForm has been deleted
 	 */
	~BC3ReviseFactory ()
	{
		delete _cons;
	}

	/// @name Base class's virtual methods
	//@{
	void create(RealConstraint & c,
	            RealVarImpl & x,
	            SetReduction & s);

	void create(ModelRep *mo,
	            SetReduction & s);

	Reduction *create(ModelRep *mo);
//@}

private:
	// Generation of interval form used by box-consistency
	IntervalFormFactory *_cons;
};

/**
 * @ingroup Reduction
 * @class HC4ReviseFactory
 * @brief Generation of a set of reductions for Hull-consistency
 * @see HullReduction
 */
class HC4ReviseFactory : public ReductionFactory
{
public:
	/**
 	 * Constructor
 	 * @param cons the factory for the intervalForm
 	 */
	HC4ReviseFactory (IntervalFormFactory *cons)
	{
		_cons = cons;
	}

	/**
 	 * Destructor
 	 * @post the factory for intervalForm has been deleted
 	 */
	~HC4ReviseFactory ()
	{
		delete _cons;
	}

	/// @name Base class's virtual methods
	//@{
	void create(ModelRep *mo,
	            SetReduction & s);
//@}

private:
	// Generation of interval form used by box-consistency
	IntervalFormFactory *_cons;
};

/**
 * @ingroup Reduction
 * @class BoxReductionFactory
 * @brief Generation of a set of reductions for box-consistency
 * @see BoxReduction
 */
class BC4Factory : public ReductionFactory
{
public:
	/**
 	 * Constructor
 	 * @param cons the factory for the intervalForm
 	 */
	BC4Factory (IntervalFormFactory *cons)
	{
		_cons = cons;
	}

	/**
 	 * Destructor
 	 * @post the factory for intervalForm has been deleted
 	 */
	~BC4Factory ()
	{
		delete _cons;
	}

	/// @name Base class's virtual methods
	//@{
	void create(ModelRep *mo,
	            SetReduction & s);

//@}

private:
	// Generation of interval form used by box-consistency
	IntervalFormFactory *_cons;
};

/**
 * @ingroup Reduction
 * @class NewtonReductionFactory
 * @brief Generation of the multidimensional interval Newton method operator
 * @see NewtonReduction
 */
class NewtonReductionFactory : public ReductionFactory
{
public:
	/// Constructor
	NewtonReductionFactory (IntervalFormFactory *createForm)
	{
		_createForm = createForm;
	}

	/// Destructor
	~NewtonReductionFactory ()
	{
		delete _createForm;
	}

	/// @name Base class's virtual method
	//@{
	void create(ModelRep *mo,
	            SetReduction & s);
	//@}

private:
	// Generation of interval form used by box-consistency
	IntervalFormFactory *_createForm;
};
END_NAMESPACE_ELISA
#endif // ELISA_INTERVAL_STRATEGY
